package com.example.apipassenger.controller;

import com.example.apipassenger.service.TokenService;
import com.example.internalcommon.dto.ResponseResult;
import com.example.internalcommon.dto.TokenResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author lyra
 * @Date 2023/4/7 16:01
 **/
@RestController
public class TokenController {

    @Autowired
    private TokenService tokenService;

    /**
     * 8.双token生成
     * @param tokenResponse
     * @return
     */
    @PostMapping("/token-refresh")
    public ResponseResult refreshToken(@RequestBody TokenResponse tokenResponse){

        String refreshTokenSrc = tokenResponse.getRefreshToken();

        System.out.println("原来的 refreshToken" + refreshTokenSrc);

        return tokenService.refreshToken(refreshTokenSrc);
    }
}
